package com.code.day19;

import java.util.Collection;
import java.util.HashMap;

public class Demo01HashMap {
    public static void main(String[] args) {
        HashMap<String,String> map1 = new HashMap<>();
        map1.put("郭靖","黄蓉");
        map1.put("杨过","小龙女");
        map1.put("杨过", "郭襄");
        map1.put("张无忌","赵敏");
        map1.put("涛哥","三上");
        System.out.println(map1);
        System.out.println("===================================");
        // remove(Object key) 输入key的值 返回的是value的值
        String remove = map1.remove("涛哥");
        System.out.println(remove);
        System.out.println(map1);
        System.out.println("===================================");
        //get(Object key) -> 根据key获取value
        String get1 = map1.get("郭靖");
        System.out.println(get1);
        System.out.println("===================================");
        //boolean containsKey(Object key)  -> 判断集合中是否包含指定的key
        System.out.println(map1.containsKey("郭靖"));
        System.out.println("===================================");
        //Collection<V> values() -> 获取集合中所有的value,转存到Collection集合中
        Collection<String> values = map1.values();
        for (String value : values) {
            System.out.println( value);
        }
        System.out.println(values);

    }
}
